#
# Cmake instructions file
#
cmake_minimum_required(VERSION 2.8)
 
include(Properties.cmake)
 
project(${NAME} CXX)

include(SBE/AddCoverityTargets)
include(SBE/DeployDependencies)
include(SBE/AddBinaryTargets)
include(SBE/AddInstallTarget)
include(SBE/AddUninstallTarget)
include(SBE/AddTagTarget)

file(GLOB SOURCE_FILES src/CppUTest/*.cpp)
file(GLOB SOURCE_FILES_EXT src/CppUTestExt/*.cpp)
file(GLOB HEADER_FILES include/CppUTest/*.h)
file(GLOB HEADER_FILES_EXT include/CppUTestExt/*.h)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "TI")
    
    add_definitions(-D=CPPUTEST_DONT_USE_EXCEPTIONS=1)
    
    file(GLOB PLATFORM_FILES src/Platforms/TiDsp/*.cpp)
    
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")

    file(GLOB PLATFORM_FILES src/Platforms/Gcc/*.cpp)

elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")

    include_directories("${PROJECT_SOURCE_DIR}/include/Platforms/VisualCpp")
	add_definitions(/FI Platform.h)
	add_definitions(/D _VC80_UPGRADE=0x0600)
	list(APPEND HEADER_FILES ${PROJECT_SOURCE_DIR}/include/Platforms/VisualCpp/stdint.h)

    file(GLOB PLATFORM_FILES src/Platforms/VisualCpp/*.cpp)

else()

    message(FATAL_ERROR "Can not configure ${NAME} for ${CMAKE_CXX_COMPILER_ID}")
            
endif()

include_directories("${PROJECT_SOURCE_DIR}/include")
    
sbeAddLibrary(
    Name ${NAME}
    Static
    Sources
        ${SOURCE_FILES} 
        ${PLATFORM_FILES}
    PublicHeaders
        ${HEADER_FILES}
)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
	target_link_libraries(${NAME} winmm)
endif()	

sbeAddLibrary(
    Name ${NAME}Ext
    Static
    Sources
        ${SOURCE_FILES_EXT}
    PublicHeaders
        ${HEADER_FILES_EXT}        
)

addInstallTarget(
    Package ${NAME}
    Targets ${NAME} ${NAME}Ext
    IncludePathReplacement 
        ".*/CppUTest/.* -> CppUTest" 
        ".*/CppUTestExt/.* -> CppUTestExt"
)
